package com.delu.service.impl;

import com.delu.config.UserOrderCountVO;
import com.delu.config.VipVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.delu.entity.TravelOrder;
import com.delu.mapper.TravelOrderMapper;
import com.delu.service.TravelOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class TravelOrderServiceimpl implements TravelOrderService {

    @Autowired
    private TravelOrderMapper travelOrderMapper;

    @Override
    public List<TravelOrder> leaseList(Integer leaseId) {

        LambdaQueryWrapper<TravelOrder> lambda = new LambdaQueryWrapper<>();

        lambda.like(TravelOrder::getLeaseId,leaseId);

        return travelOrderMapper.selectList(lambda);

    }

    @Override
    public List<TravelOrder> orderList(Integer userId) {

        LambdaQueryWrapper<TravelOrder> lambda = new LambdaQueryWrapper<>();
        lambda.like(TravelOrder::getUserId,userId);

        return travelOrderMapper.selectList(lambda);
    }

    @Override
    public List<TravelOrder> orderto(TravelOrder travelOrder) {

        LambdaQueryWrapper<TravelOrder> lambda = new LambdaQueryWrapper<>();
        lambda.like(TravelOrder::getOrderId,travelOrder.getOrderId()).and(la -> la.like(TravelOrder::getStartTime,travelOrder.getStartTime()));

        return travelOrderMapper.selectList(lambda);
    }

    @Override
    public List<TravelOrder> refund(Integer userId) {

        LambdaQueryWrapper<TravelOrder> lambda = new LambdaQueryWrapper<>();
        lambda.like(TravelOrder::getUserId,userId).and(la->la.like(TravelOrder::getOrderStatus,6));
        List<TravelOrder> travelOrders = travelOrderMapper.selectList(lambda);
        return travelOrders;
    }

    @Override
    public List<VipVO> orderVipList() {

        List<VipVO> ddd = travelOrderMapper.ddd();

        return ddd;
    }

    @Override
    public List<UserOrderCountVO> userOrderCount() {

        List<UserOrderCountVO> userOrderCountVOS = travelOrderMapper.userOrderCount();

        return userOrderCountVOS;
    }
}
